#include<bits/stdc++.h>
using namespace std;

int a[1000010], dp[1000010];

int main() {
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += a[i];
	}

	dp[0] = sum;
	dp[1] = sum - a[1];
	for (int i = 2; i <= n; i++)
		dp[i] = min(dp[i - 1], dp[i - 2] - a[i]);
//	for(int i = 1;i <= n;i++)
//		cout<<dp[i]<<endl;
	cout << dp[n];
}
